package com.example.hotel_demo.utils;

import com.example.hotel_demo.pojo.Book;
import com.example.hotel_demo.service.MailService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Random;

@Service
public class MailUtil {
    @Autowired
    private MailService mailService;

    public String getCheckCode(String email){
        String checkCode = String.valueOf(new Random().nextInt(888888)+10000);
        String message = "验证码：" + checkCode;
        System.out.println(message);
        mailService.sendCheckCode(email,"注册验证码",checkCode);
        return checkCode;
    }
    public void sendGood(String email, Book book,String custName){
        String message = "尊贵的客户："+ custName+"   您好,您于"+ book.getCreateTime() +"预订的客房,预订成功,请于"+book.getArriveDate() +"前办理入住" ;
        System.out.println(message);
       // mailService.sendGood(email,"预订信息",message);
    }

    public void sendBad(String email, Book book,String custName){

        String message = "尊贵的客户："+ custName+"   您好,您于"+ book.getCreateTime()  +"预订的客房,预订失败,感谢您对酒店的支持，有需要请重新进行预订" ;
        System.out.println(message);
        //mailService.sendGood(email,"预订信息",message);
    }
}
